package com.dime.physical.controller;

import com.dime.physical.domain.DimeInquiryitems;
import com.dime.physical.domain.DimePhysicalregister;
import com.dime.physical.domain.dto.InquiryDto;
import com.dime.physical.domain.dto.InquiryPhysicalregister;
import com.dime.physical.domain.dto.PhysicalDto;
import com.dime.physical.domain.dto.SearchPhysicalregister;
import com.dime.physical.service.IDimeInquiryService;
import com.dime.physical.service.IDimePhysicalregisterService;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * 保存问诊项目Controller
 *
 * @author Tiny
 * @date 2023-10-07
 */
@RestController
@RequestMapping("/inquiry")
public class DimeInquiryController extends BaseController {

    @Autowired
    private IDimePhysicalregisterService dimePhysicalregisterService;


    @Autowired
    private IDimeInquiryService dimeInquiryService;


    @RequiresPermissions("physical:inquiry:list")
    @GetMapping("/list")
    public List<InquiryPhysicalregister> getTodayRegisterinquirylist() {

        SearchPhysicalregister physicalregister = new SearchPhysicalregister();

        String start = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.getNowDate());
        String end = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, DateUtils.addDays(DateUtils.getNowDate(), +1));
        physicalregister.setNeedAsk("1");
//        physicalregister.setBeginTime(start);
//        physicalregister.setEndTime(end);
       // List<DimePhysicalregister> list = dimePhysicalregisterService.getTodayRegisterinquirylist(physicalregister);

        List<InquiryPhysicalregister> list= dimePhysicalregisterService.selectDimePhysicalregisterinquiryList(physicalregister);
        return list;
    }


    @RequiresPermissions("physical:inquiry:getRegisterinquiryBywhere")
    @GetMapping(value = "getRegisterinquiryBywhere")
    public List<InquiryPhysicalregister> getRegisterinquiryBywhere(SearchPhysicalregister searchPhysicalregister) {

        searchPhysicalregister.setNeedAsk("1");
        List<InquiryPhysicalregister> list= dimePhysicalregisterService.selectDimePhysicalregisterinquiryList(searchPhysicalregister);
        return list;
    }


    @RequiresPermissions("physical:inquiry:getRegisterinquiryByPhysical")
    @PostMapping("/getRegisterinquiryByPhysical")
    public InquiryDto getRegisterinquiryByPhysical(@RequestBody DimePhysicalregister dimePhysicalregister) {

        InquiryDto inquiryDtos = dimeInquiryService.inquiryDto(dimePhysicalregister.getCheckCode());
        return inquiryDtos;
    }



    @RequiresPermissions("physical:inquiry:getRegisterinquiryBycheckcode")
    @GetMapping("/getRegisterinquiryBycheckcode/{checkCode}")
    public InquiryDto getRegisterinquiryBycheckcode(@PathVariable("checkCode") String checkCode) {

        InquiryDto inquiryDtos = dimeInquiryService.inquiryDto(checkCode);
        return inquiryDtos;
    }



    @RequiresPermissions("physical:inquiry:Saveinquiry")
    @Log(title = "问诊保存", businessType = BusinessType.OTHER)
    @PostMapping("/Saveinquiry")
    public AjaxResult Saveinquiry(@RequestBody InquiryDto inquiryDto) {

        return success(dimeInquiryService.Saveinquiry(inquiryDto));

    }



    @RequiresPermissions("physical:inquiry:Revokeinquiry")
    @Log(title = "撤销问诊", businessType = BusinessType.OTHER)
    @PostMapping("/Revokeinquiry")
    public AjaxResult Revokeinquiry(@RequestBody DimePhysicalregister dimePhysicalregister) {

        return success(dimeInquiryService.Revokeinquiry(dimePhysicalregister));

    }


}
